<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    .tab_box{
      width: 300px;
      height: 400px;
      border: 1px solid red;
      margin: 40px auto;
      box-sizing: border-box;
    }
    .title{
      width: 100%;
      height: 50px;
      border-bottom: 1px solid #ccc;
    }
    .title li{
      width: 33.3%;
      float: left;
      height: 50px;
      line-height: 50px;
      text-align: center;
    }
    .title a{
      display:block;
      width: 100%;
      text-decoration: none;
    }
    .content{
      height: 350px;
    }
    .content>div{
      height: 350px;
      padding: 50px 30px;
      box-sizing: border-box;
    }
    .content li{
      height: 30px;
      line-height: 30px;
    }
    .active{
      background-color:orange;
      color:white;
    }
  </style>
</head>
<body>
  <div class="tab_box">
    <div class="title">
      <ul>
        <li><a href="javastript:;" data-name="sell" class="active">促销</a></li>
        <li><a href="javastript:;" data-name="notice">公告</a></li>
        <li><a href="javastript:;" data-name="more">更多</a></li>
      </ul>
    </div>
    <div class="content">
      <div class="more public" id="more" style="display: block">
        <ul>
          <li>TCL空调制暖季 2017-10-17</li>
          <li>TCL空调制暖季 2017-10-17</li>
          <li>TCL空调制暖季 2017-10-17</li>
          <li>TCL空调制暖季 2017-10-17</li>
        </ul>
      </div>
      <div class="sell public" id="sell" style="display: none">
        <ul>
          <li>家纺自营满199减100</li>
          <li>200元优惠券限量抢！</li>
          <li>智能家电领券100减50</li>
          <li>每日享折扣 京东品质游</li>
        </ul>
      </div>
      <div class="notice public" id="notice" style="display: none">
        <ul>
          <li>京东全球售升级 新域名同</li>
          <li>京东知识服务正式上线 打造</li>
          <li>东大件物流“送装一体</li>
          <li>京东全球售升级 新域名同</li>
        </ul>
      </div>
    </div>
  </div>
  <script>
    var a_btns = document.querySelectorAll('.title a');
    var publics = document.querySelectorAll('.content .public')
    console.log(publics)
    for(var i = 0; i < a_btns.length; i++){
      a_btns[i].onclick = function(){
        for(var j = 0; j < a_btns.length; j++){
          a_btns[j].classList.remove('active');
        }
        this.classList.add('active');
        var content_id = document.getElementById(this.dataset.name);
        for(var k = 0; k < publics.length; k++){
          publics[k].style.display = "none";
        }
        content_id.style.display = "block";

      }
   
    }
  </script>
</body>
</html>